Skip to content

fix(Connectors.Google): use embedContent API for gemini-embedding models - #14266

Open
Diwakar Ray Yadav (Diwak4r) wants to merge 1 commit into
microsoft:mainfrom
Diwak4r:fix/vertex-embedcontent
Open

fix(Connectors.Google): use embedContent API for gemini-embedding models#14266
Diwakar Ray Yadav (Diwak4r) wants to merge 1 commit into
microsoft:mainfrom
Diwak4r:fix/vertex-embedcontent

Conversation

@Diwak4r

Copy link
Copy Markdown

What changed

VertexAIEmbeddingGenerator hardcodes the :predict endpoint for every model. That method is no longer served for gemini-embedding-* models, so using e.g. gemini-embedding-2 fails with 400 FAILED_PRECONDITION.

This PR routes embedding requests by model family:

  • gemini-embedding-* models → the :batchEmbedContents method, with the requests[].content.parts[].text payload shape and the embeddings[].values response shape.
  • All other models (text-embedding-*, multimodalembedding, etc.) → unchanged :predict path with the existing instances payload.

Why this shape

batchEmbedContents is the batched equivalent of embedContent — it maps 1:1 onto the client's existing behavior of embedding a list of strings in a single HTTP call, and returns embeddings in input order. outputDimensionality is forwarded exactly as before.

Tests

Added to VertexAIClientEmbeddingsGenerationTests (red → green):

  • ShouldUseBatchEmbedContentsEndpointForGeminiEmbeddingModelAsync — asserts :batchEmbedContents endpoint + requests[].content.parts[].text body for gemini-embedding-2.
  • ShouldUsePredictEndpointForLegacyEmbeddingModelAsync — asserts :predict endpoint + instances body for text-embedding-004 (regression guard).
  • ShouldReturnValidEmbeddingsResponseForGeminiEmbeddingModelAsync — parses a new vertex_embed_content_response.json fixture into vectors.

Full Connectors.Google.UnitTests suite: 437 passed, 0 failed.

Fixes #14265

@Diwak4r
Diwakar Ray Yadav (Diwak4r) requested a review from a team as a code owner August 4, 2026 08:10
Copilot AI lite review requested due to automatic review settings August 4, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 67% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by Diwak4r's agents

@Diwak4r

Copy link
Copy Markdown
Author

Just verifying this is still in the review queue. All checks green, branch is mergeable. Happy to address any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: VertexAIEmbeddingGenerator hardcodes :predict, unusable with gemini-embedding models that only serve :embedContent

2 participants